package cz.vutbr.fit.xzemko01.tfmcbs.validation.validators;

import java.util.Map;

import org.eclipse.emf.common.util.DiagnosticChain;

import cz.vutbr.fit.xzemko01.tfmcbs.model.Component;
import cz.vutbr.fit.xzemko01.tfmcbs.model.Provider;
import cz.vutbr.fit.xzemko01.tfmcbs.model.Requier;
import cz.vutbr.fit.xzemko01.tfmcbs.model.SimpleComponent;

public final class SimpleComponentValidator implements Validator<SimpleComponent> {
	
	private static SimpleComponentValidator simpleComponentValidator;
	
	private Validator<Component> componentValidator;
	private Validator<Requier> requierValidator;
	private Validator<Provider> providerValidator;
	
	private SimpleComponentValidator() {
		componentValidator = ComponentValidator.getInstance();
		requierValidator = RequierValidator.getInstance();
		providerValidator = ProviderValidator.getInstance();
	}
	
	public static Validator<SimpleComponent> getInstance() {
		if(simpleComponentValidator == null) {
			simpleComponentValidator = new SimpleComponentValidator();
		}
		return simpleComponentValidator;
	}
	@Override
	public boolean validate(SimpleComponent component, DiagnosticChain diagnostics, Map<Object, Object> context) {
		boolean result = componentValidator.validate(component, diagnostics, context);
		result &= requierValidator.validate(component, diagnostics, context);
		result &= providerValidator.validate(component, diagnostics, context);
		
		return result;
	}
}
